<!DOCTYPE html>
<html>
<head>
    {include file='public/meta'/}
    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrapSwitch.css">

    <script src="__STATIC_URL__/static/js/bootstrapSwitch.js"></script>

    <style>

        @media (min-width: 768px) {
            .modal-dialog {
                width: 600px;
                margin: 200px auto;
            }
        }
        </style>
</head>
<body>
{include file='public/header'/}
<!------------------导航-------------------------->
<section>
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">

        <div class="panel mgl15 mgr15">
            <div class="panel-body">
                <!--路径导航-->
                <ol class="breadcrumb">
                    <li>当前位置是&nbsp;:</li>
                    <li><a href="javascript:history.back();">营销工具</a></li>
                    <li><a href="javascript:history.back(-2)">活动营销</a></li>
                    <li>
                        <a href="javascript:history.back(-1);">易订货</a>
                    </li>
                    <li class="active" style="color: #02b87f;">
                        基础设置
                    </li>
                </ol>
                <div>


                    <div class="panel panel-default ng-scope">
                        <form action="" method="post"  id="formcate">
                            <div class="panel-heading">
                                基础设置
                            </div>
                            <div class="panel-body">
                                <div class="row">
                                    <div class="col-sm-10">

                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">用户名：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">

                                                    <input type="text" name="username" id="userName" class="form-control" maxlength="12"  placeholder="" value="{$info['username']}" />
                                                </div>
                                            </div>
                                        </div>


                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">密码：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">
                                                    <input type="password" name="password" class="form-control" id="password"   placeholder="" value="{$info['password']}" />
                                                </div>
                                            </div>
                                        </div>

                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">设备ID：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">
                                                    <input type="text" name="client_id" class="form-control" id="client_id"  placeholder="" value="{$info['client_id']}" />
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">设备秘钥：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="client_secret" id="client_secret" placeholder="" value="{$info['client_secret']}"  />
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">购买用户类别：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">
                                                    <select name="price_cate_id" id="price_cate_id" class="form-control">

                                                        {volist name="catelist" id="vo"}
                                                        <option value="{$vo['cate_id']}" {if condition="$info['price_cate_id'] eq $vo.cate_id"}selected{/if}>{$vo.name}</option>
                                                        {/volist}
                                                    </select>                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">默认用户类别：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">
                                                    <select name="default_cate_id" id="default_cate_id" class="form-control">

                                                        {volist name="catelist" id="vo"}
                                                        <option value="{$vo['cate_id']}" {if condition="$info['default_cate_id'] eq $vo.cate_id"}selected{/if}>{$vo.name}</option>
                                                        {/volist}
                                                    </select>                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">价格：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">
                                                    <input type="number" name="price" class="form-control" id="price"   placeholder="" value="{$info['price']}" />
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                </div>

                            </div>
                            <div class="panel-footer" style="text-align: center;">
                                <button class="btn btn-success" type="button" onclick="btn();" style="padding:8px 30px;">保存</button>
                            </div>
                        </form>
                    </div>
                    <div class="panel panel-default ng-scope">
                        <form class="form-horizontal" name="form" id="form" style="max-width: 900px;">
                            <div class="panel-heading">
                                常用链接
                            </div>
                            <div class="panel-body">
                            <div class="form-group">
                                <label class="control-label col-sm-3">会员注册链接：</label>
                                <div class="col-sm-9">
                                    <textarea type="text" rows="2" style="resize: none;" readonly class="form-control" placeholder="">{$info.ydh_index_url}</textarea>
                                </div>
                            </div>
                            </div>
                        </form>
                    </div>

                </div>
            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>
<script>
    function btn(){
        var userName=$("#userName").val();

        var password = $('#password').val();

        var client_id=$("#client_id").val();

        var client_secret=$("#client_secret").val();

        var price_cate_id=$("#price_cate_id").val();

        var default_cate_id=$("#default_cate_id").val();

        if(userName==""){
            layer.msg('请填写用户名！');
            return false;
        }

        if(password==""){
            layer.msg('请填写密码！');
            return false;
        }
        if(client_id==""){
            layer.msg('请填写设备ID。');
            return false;
        }

        if(client_secret==""){
            layer.msg('请填写设备秘钥。');
            return false;
        }
        if(price_cate_id==""){
            layer.msg('请填写购买用户类别。');
            return false;
        }
        if(default_cate_id==""){
            layer.msg('请填写默认用户类别。');
            return false;
        }


        $.ajax({
            url: "{:url('')}",
            type: "post",
            data: $("#formcate").serialize(),
            success: function (data) {
                // console.log(data);
                if(data.code==0){
                    layer.msg(data.message);
                    setTimeout(function(){
                        window.location.href = "{:url('ydhmarke/ydhindex')}";

                    },1500)
                }else{
                    layer.msg(data.message);
                }
            }
        })
    }
</script>
</body>

</html>
